﻿using LPY.LeHealth.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace LPY.LeHealth.WebSite.Controllers
{
    public class HomeController : BaseController
    {
        private PhysicalService physicalService;
        private CartService carService;
        public HomeController()
        {
            physicalService = new PhysicalService();
            carService = new CartService();
        }

        /// <summary>
        /// 首页显示
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            var pageSize = 4;
            long totalSize = 0;
            //获取套餐列表
            var comboList = physicalService.GetPhysicalComboDTO(1, pageSize, out totalSize);
            //获取单项体检列表
            var singleList = physicalService.GetPhysicalSingleDTO(1, pageSize, out totalSize);

            ViewBag.ComboList = comboList;
            ViewBag.SingleList = singleList;

            ViewBag.cName = Session["cityname"];
            return View();
        }

        /// <summary>
        /// 套餐详情
        /// </summary>
        /// <returns></returns>
        public ActionResult ComboDetail(int id)
        {
            var combo = physicalService.GetCombo(id);
            ViewBag.Combo = combo;

            return View();
        }

        /// <summary>
        /// 购物车
        /// </summary>
        /// <returns></returns>
        [Common.User]
        public ActionResult Cart()
        {
            //购物车列表
            var comboList = carService.GetListByUserId(CurrentUser.Id);
            ViewBag.ComboList = comboList;

            return View();
        } 

        //添加到购物车
        [HttpPost]
        [Common.User]
        public ActionResult AddCar(int comboId,int count)
        {
            var result = false;
            result= carService.Add(CurrentUser.Id, comboId, count);
            if(result)
            {
                return Json(new { Code = 1, Msg = "添加成功" });
            }
            else
            {
                return Json(new { Code = 0, Msg = "添加失败" });
            }
        }

        /// <summary>
        /// 套餐列表显示
        /// </summary>
        /// <returns></returns>
        public ActionResult Combo()
        {
            return View();
        }

        /// <summary>
        /// 单项体检
        /// </summary>
        /// <returns></returns>
        public ActionResult Personalized()
        {
            return View();
        }

        /// <summary>
        /// 优惠模块（领取优惠）
        /// </summary>
        /// <returns></returns>
        public ActionResult Promotion()
        {
            return View();
        }

        /// <summary>
        /// 生成订单
        /// </summary>
        /// <returns></returns>
        public ActionResult CreateOrder()
        {
            return View();
        }

        /// <summary>
        /// 支付页面
        /// </summary>
        /// <returns></returns>
        public ActionResult Pay()
        {
            return View();
        }


        /// <summary>
        /// 我的订单
        /// </summary>
        /// <returns></returns>
        public ActionResult MyOrder()
        {
            return View();
        }

        /// <summary>
        /// 订单详情
        /// </summary>
        /// <returns></returns>
        public ActionResult OrderDetail()
        {
            return View();
        }

        /// <summary>
        /// 用户资料
        /// </summary>
        /// <returns></returns>
        public ActionResult UserInfo()
        {
            return View();
        }

        /// <summary>
        /// 用户安全设置
        /// </summary>
        /// <returns></returns>
        public ActionResult UserSafeSet()
        {
            return View();
        }

        /// <summary>
        /// 我的优惠券
        /// </summary>
        /// <returns></returns>
        public ActionResult MyPromotion()
        {
            return View();
        }

        /// <summary>
        /// 体检知识库
        /// </summary>
        /// <returns></returns>
        public ActionResult Zhishiku()
        {
            return View();
        }


        /// <summary>
        /// 体检知识库文章详情
        /// </summary>
        /// <returns></returns>
        public ActionResult ZArticle()
        {
            return View();
        }


        /// <summary>
        /// 健康小贴士
        /// </summary>
        /// <returns></returns>
        public ActionResult Xiaotieshi()
        {
            return View();
        }


        /// <summary>
        /// 健康小贴士文章详情
        /// </summary>
        /// <returns></returns>
        public ActionResult XArticle()
        {
            return View();
        }



        /// <summary>
        /// 支付宝支付页面
        /// </summary>
        /// <returns></returns>
        public ActionResult PayDemo()
        {
            return View();
        }




        /// <summary>
        /// 确定预约时间 
        /// </summary>
        /// <returns></returns>
        public ActionResult Appointment()
        {
            return View();
        }


        /// <summary>
        /// 体检人员管理
        /// </summary>
        /// <returns></returns>
        public ActionResult ExaminationPeople()
        {
            return View();
        }

        /// <summary>
        /// 个人消息
        /// </summary>
        /// <returns></returns>
        public ActionResult Message()
        {
            return View();
        }

        /// <summary>
        /// 报告查询
        /// </summary>
        /// <returns></returns>
        public ActionResult Report()
        {
            return View();
        }

        /// <summary>
        /// 待预约订单
        /// </summary>
        /// <returns></returns>
        public ActionResult AppointmentOrder()
        {
            return View();
        }

        /// <summary>
        /// 医院后台显示
        /// </summary>
        /// <returns></returns>
        public ActionResult Hospital()
        {
            return View();
        }

        /// <summary>
        /// 系统后台
        /// </summary>
        /// <returns></returns>
        public ActionResult AdminMenu()
        {
            return View();
        }

        /// <summary>
        /// 用户管理
        /// </summary>
        /// <returns></returns>
        public ActionResult UserManager()
        {
            return View();
        }

        /// <summary>
        /// 优惠管理
        /// </summary>
        /// <returns></returns>
        public ActionResult PromotionManager()
        {
            return View();
        }


        /// <summary>
        /// 机构管理
        /// </summary>
        /// <returns></returns>
        public ActionResult HospitalManager()
        {
            return View();
        }
       

       
    }
}